<?php
/**
 * Widget for displaying content of two categories (daul widget) on home page
 *
 * Used for both single and index/archive/search.
 *
 * @package WordPress
 * @subpackage lebanontimes
 * @since Lebanon Times 1.0
 */

include dirname(__FILE__)."/categoryMapping.php";
?>

<?php if (get_category($categoryMapping['breaking-news'][0])->category_count > 0) { ?>
    <?php $posts = get_posts("category={$categoryMapping['breaking-news'][0]}&numberposts=1");
    foreach($posts as $post) {
        $difference = current_time('timestamp') - get_the_time('U');
        $difference = $difference / 3600;

        if ($difference < 2) {
        ?>
        <!-- Breaking News -->
        <div class="breaking-news">
            <span><?php echo get_the_category_by_ID( $categoryMapping['breaking-news'][0] );?>... </span>
            <?php $posts = get_posts("category={$categoryMapping['breaking-news'][0]}&numberposts=1");
            foreach($posts as $post) { 
                the_title();
            } ?>
        </div>
        <?php 
        }
    } 
} ?>